program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
Summator = class
n: integer;
procedure sum;
end;

SmartSummator = class (Summator)
  n: integer;
procedure sum;
end;

{ SmartSummator }

procedure SmartSummator.sum;
var l: real;
begin
l:=n*(n+1)/2;
Writeln(l:0:0);
end;

procedure Summator.sum;
var i, l:integer;
begin
  l:=0;
for i:=1 to n do
  l:=l+i;
  writeln (l);
end;

var
  a:SmartSummator;
  b:Summator;
  n: integer;
begin
  writeln ('Enter the number:');
  a:=SmartSummator.Create;
  b:=Summator.Create;
  Readln (n);
  a.n:=n;
  b.n:=n;
  a.sum;
  {b.sum;}
readln;
end.
